package com.chenfan.ccp.plug.mq.hander;

import com.chenfan.ccp.plug.log.trace.TraceLog;
import feign.codec.ErrorDecoder;
import org.springframework.context.annotation.Bean;


/**
 * 暂时不做全局处理
 */
public class RpcErrorConfiguration {


    private TraceLog log = new TraceLog();

    @Bean
    public ErrorDecoder feignError() {
        return (key, response) -> {
            //访问服务并未建立完全
            if (response.status() == 400 || response.status() == 409 ||
                    response.status() == 404) {

                log.log("服务={} 发生错误，消息体为={},请及时处理!!", key, response);
                //TODO:叮叮消息
            }


            return new ErrorDecoder.Default().decode(key, response);
        };
    }

}